package frog.whacker;

import java.util.ArrayList;
import java.util.Random;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class FrogDestroyer extends Thread {
    private Panel mPanel;
    private SurfaceHolder mHolder;
	private long mRoundTime;
	private ArrayList<Frogs> mFrogs = new ArrayList<Frogs>();
	private int mX;
	private int mY;
    
    public FrogDestroyer(Panel panel,ArrayList<Frogs> iFrogs,int X,int Y){
        mPanel = panel;
        mHolder = mPanel.getHolder();
        mX = X;
        mY = Y;
        mFrogs.addAll(iFrogs);
    }
            
    @Override
    
    //Continuous game mode
    public void run() 
    {
    	 synchronized (mFrogs) {
             for (Frogs element : mFrogs) {
                 if (element.checklocation(mX, mY)){
                	 int x = mFrogs.indexOf(element);
                	 mFrogs.remove(x+1);
                	 mFrogs.remove(x);
                	 Canvas canvas = null;
                	 canvas = mHolder.lockCanvas();
            	        if (canvas != null) 
            	        {
            	        	mPanel.doDraw(mFrogs, canvas);
            	            mHolder.unlockCanvasAndPost(canvas);
            	            mPanel.mPost = false;
            	        }
                	 return;
                 }
             }
         }
    	 
    }
}
        
        
       